Normalize paths before checking for equality
authorAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 3 Jan 2017 11:11:57 +0000 (14:11 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 7 Jan 2017 17:46:35 +0000 (20:46 +0300)
src/cargo/core/workspace.rs
tests/workspaces.rs

index 870733f96d9992d0734aca4a6ca2398a96d3ad39..fa5a14e719c966b1600bb23e6117c8b5a4594254 100644 (file)
@@ -304,15 +304,16 @@ impl<'cfg> Workspace<'cfg> {
     }
 
     fn find_path_deps(&mut self, manifest_path: &Path) -> CargoResult<()> {
-        if self.members.iter().any(|p| p == manifest_path) {
+        let manifest_path = paths::normalize_path(manifest_path);
+        if self.members.iter().any(|p| p == &manifest_path) {
             return Ok(())
         }
 
         debug!("find_members - {}", manifest_path.display());
-        self.members.push(manifest_path.to_path_buf());
+        self.members.push(manifest_path.clone());
 
         let candidates = {
-            let pkg = match *self.packages.load(manifest_path)? {
+            let pkg = match *self.packages.load(&manifest_path)? {
                 MaybePackage::Package(ref p) => p,
                 MaybePackage::Virtual(_) => return Ok(()),
             };
index 8204e6c341c8386d5bc49f8aba2196ee6e6e13da..b84388813f1e3b6ea5f9f5fbafd0b8e5361e884d 100644 (file)
@@ -1074,3 +1074,30 @@ fn error_if_parent_cargo_toml_is_invalid() {
                        .with_stderr_contains("\
 [ERROR] failed to parse manifest at `[..]`"));
 }
+
+#[test]
+fn relative_path_for_member_works() {
+    let p = project("foo")
+        .file("foo/Cargo.toml", r#"
+        [project]
+        name = "foo"
+        version = "0.1.0"
+        authors = []
+
+        [workspace]
+        members = ["../bar"]
+    "#)
+        .file("foo/src/main.rs", "fn main() {}")
+        .file("bar/Cargo.toml", r#"
+        [project]
+        name = "bar"
+        version = "0.1.0"
+        authors = []
+        workspace = "../foo"
+    "#)
+        .file("bar/src/main.rs", "fn main() {}");
+    p.build();
+
+    assert_that(p.cargo("build").cwd(p.root().join("foo")), execs().with_status(0));
+    assert_that(p.cargo("build").cwd(p.root().join("bar")), execs().with_status(0));
+}
\ No newline at end of file